<template>
    <div class="apiForm">
        <el-row>
            <el-col :md="10" :offset="7">
                <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="108px" class="demo-ruleForm">
                    <el-form-item
                        label="产品名称"
                        prop="name"
                    >
                        <el-input v-model="ruleForm.name" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item
                        label="运营商套餐ID"
                        prop="idname"
                    >
                        <el-input v-model="ruleForm.idname" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item
                        label="产品种类"
                    >
                        <el-radio-group v-model="ruleForm.type">
                            <el-radio label="1">流量</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item
                        label="服务类型"
                    >
                        <el-radio-group v-model="ruleForm.service">
                            <el-radio label="1">流量包</el-radio>
                            <el-radio label="">加餐包</el-radio>
                            <el-radio label="">流量池</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item
                        label="服务周期"
                    >
                        <el-radio-group v-model="ruleForm.circle">
                            <el-radio label="1">月</el-radio>
                            <el-radio label="">季</el-radio>
                            <el-radio label="">半年</el-radio>
                            <el-radio label="">年</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item
                        label="流量单位"
                    >
                        <el-radio-group v-model="ruleForm.traffic">
                            <el-radio label="1">单位（MB）</el-radio>
                            <el-radio label="">单位（GB）</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item
                        label="服务容量"
                        prop="volume"
                    >
                        <el-input  v-model="ruleForm.volume" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item
                        label="产品有效性"
                    >
                        <el-radio-group v-model="ruleForm.isActivity">
                            <el-radio label="1">有效</el-radio>
                            <el-radio label="">失效</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item
                        label="产品价格"
                        prop="productPrice"
                    >
                        <el-input  v-model="ruleForm.productPrice" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
                        <el-button @click="resetForm('ruleForm')">取消</el-button>
                    </el-form-item>
                </el-form>
            </el-col>
        </el-row>
    </div>

</template>
<script>
    export default {
    data() {
      return {
        ruleForm: {
            name: '',
          idname: '',
          type: '1',
          service: '1',
          circle: '1',
          traffic: '1',
          volume: '',
          isActivity: '1',
          productPrice: ''



        },
        rules: {
          name: [
            { required: true, message: '请输入产品名称', trigger: 'blur' }
          ],
          idname: [
            {required: true, message: '请输入运营商套餐ID', trigger: 'blur' }
          ],
          volume: [
            { required: true, message: '请输入服务容量', trigger: 'blur' }
          ],
          productPrice: [
            { required: true, message: '请输入产品价格', trigger: 'blur' }
          ]
        }
      };
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('submit!');
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
        this.$router.push({
            path: '/carrier/' + this.$store.getters.carrier.carrierId +'/carrier_product'
        })
      }
    }
    }
</script>
<style lang="scss" scoped>
    .select {
        width: 100%;
    }
</style>

